<template>
	<view class="pb40">
		<view class="plr20 mt20 ">
			<!-- tab -->
			<view class="gridItem-box plr20 pt20 rd20">
				<view class="grb-list" v-for="(item, index) in tabList" :key="index" @click="goActive(index,item.num)">
					<view class="cXY" :class="activeCurrent===index?'activeIconBox':'iconBox'">
						<image :src="activeCurrent===index? item.activeIcon :item.icon"
							:class="activeCurrent===index? 'active-img' :'category-img'">
						</image>
					</view>
					<view :class="activeCurrent===index?  'gridActive-text': ' grid-text'">{{item.name}}</view>
				</view>
			</view>
		</view>
		<!-- 折叠面板 -->
		<view class="plr20 mt30">
			<view class="collapse-Box rd20 plr30 ">
				<view class="f32 pt20 mb20 rimb2 pb20" style="font-weight: 600;margin-bottom: -10rpx;">
					{{title}}
				</view>
				<view class="mt10" v-if="problemList.length>0">
					<u-collapse :item-style="itemStyle" :body-style="bodyStyle" :head-style="headStyle"
						event-type="close" :arrow="arrow" :accordion="false">
						<u-collapse-item ref="collapseHeight" @change="handleOpenChange(item,index)" :title="item.name"
							v-for="(item, index) in problemList" :key="index">
							<view class="collapse-item">
								<u-parse :html="item.detail" :selectable="true" :lazy-load="true" :tag-style="style"
									:show-with-animation="true"></u-parse>
							</view>
						</u-collapse-item>
					</u-collapse>
				</view>
				<view class="mt20" v-else>
					<u-empty text="暂无数据" mode="list"></u-empty>
				</view>
			</view>
		</view>
		<view class="mt40 tc ">
			<view class="cX">
				<view class="disSolve f30">没解决您的问题?</view>
				<view style="padding:3rpx;">
					<contact-button :tnt-inst-id="information.tntInstId" :scene="information.scene" size="52"
						:alipay-card-no="thirdId" icon="../../static/keFu/call.png" />
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getZWZUserDetail,
	} from "@/utils/index.js"
	import {
		queryOpeNotice,
		queryCustomerService
	} from '../../api/index.js'
	export default {
		data() {
			return {
				tabId: '',
				information: '',
				thirdId: getZWZUserDetail().thirdId,
				headStyle: {
					fontSize: '32rpx'
				}, //折叠面板里面头部样式
				itemStyle: {
					borderBottom: '2rpx solid #F2F2F2',
				},
				bodyStyle: {
					fontSize: '30rpx',
				}, //折叠面板里面内容样式
				style: {
					// 字符串的形式
					// p: 'color: red;font-size:32rpx',
					// span: 'font-size: 30rpx'
				}, //富文本样式
				title: '', //问题标题
				activeCurrent: 0,
				tabList: [], //tab列表数据
				problemList: [], //tab对应的折叠面板数据
			}
		},
		onLoad(e) {
			this.information = this.$getGlobalData("information")
			if(e){
				this.activeCurrent = Number(e.num)
				queryOpeNotice({
					method: 'POST',
					data: {}
				}).then(res => {
					if (res.statusCode === 200) {
						this.tabList = res.data.data.tabList
						this.title = this.tabList[this.activeCurrent].name
						this.tabId = this.tabList[this.activeCurrent].id
						this.queryCustomerService()
					}
				})
			}
		},
		methods: {
			// 点击折叠面板,动态获取面板的高度
			handleOpenChange(item, index) {
				setTimeout(() => {
					this.$refs.collapseHeight[index].queryRect();
				}, 50);

			},
			goActive(index, num) {
				this.problemList = []
				this.activeCurrent = index
				this.title = this.tabList[index].name
				this.tabId = this.tabList[index].id
				this.queryCustomerService()
			},
			// tab
			queryOpeNotice() {
				queryOpeNotice({
					method: 'POST',
					data: {}
				}).then(res => {
					if (res.statusCode === 200) {
						this.tabList = res.data.data.tabList
					}
				})
			},
			// 点击tab对应的问题列表
			queryCustomerService() {
				queryCustomerService({
					method: 'POST',
					data: {
						tabId: this.tabId,
						pageNumber: 1,
						pageSize: 100
					}
				}).then(res => {
					if (res.statusCode === 200) {
						this.problemList = res.data.data.records
					}
				})
			}

		}
	}
</script>
<style scoped>
	.collapse-item {
		letter-spacing:3rpx;
		line-height: 40rpx;
		color:#82848a;
	}
</style>
<style>
	page {
		height: 100vh;
		width: 750rpx;
		background-color: #F6F6F6;
	}

	.activeIconBox {
		width: 110rpx;
		height: 110rpx;
		border-radius: 50%;
	}

	.iconBox {
		width: 110rpx;
		height: 110rpx;
		border-radius: 50%;
		background-color: #F2F2F2;
	}

	.category-img {
		width: 50rpx;
		height: 50rpx;
	}

	.active-img {
		width: 110rpx;
		height: 110rpx;
	}

	.gridItem-box {
		display: flex;
		align-items: center;
		flex-wrap: wrap;
		background-color: #FFFFFF;
	}

	.collapse-Box {
		background-color: #FFFFFF;
	}

	.grb-list {
		width: 20%;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.grid-text {
		font-size: 22rpx;
		margin-top: 10rpx;
		color: $u-type-info;
		margin-bottom: 25rpx;
	}

	.gridActive-text {
		font-size: 22rpx;
		margin-top: 10rpx;
		color: #0DC8C1;
		margin-bottom: 25rpx;
	}

	.disSolve {
		color: #A5A5A5;
	}
</style>
